<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'category-form',
    //'enableAjaxValidation' => false,
    'enableClientValidation' => true,
    'htmlOptions' => array(
        'enctype' => 'multipart/form-data',
        'class' => 'form-horizontal',
    ),
        ));
?>
<div class="tabbable">

    <div class="tab-content">
        <div class="row-fluid">
            <div class="span12">
                <!--PAGE CONTENT BEGINS-->
                <div class="control-group">
                    <label class="control-label">Thứ tự hiện thị</label>
                    <div class="controls">
                        <?php echo $form->textField($model, "order", array('size' => 60, 'maxlength' => 100, 'class' => 'span5', 'placeholder' => 'Thứ tự hiện thị')); ?>
                        <span class="help-inline"><?php echo $form->error($model, 'order'); ?></span>
                    </div>
                </div>
                <?php
                $cate = MyFunctionCustom::getCategoryParent();
                //echo "<pre>";print_r($menu);
                if (count($cate) > 0):
                    ?>
                    <div class="control-group">
                        <label class="control-label">Danh mục cha</label>
                        <div class="controls">
                            <select id="category" name="Category[parent]">
                                <option value="0">--</option>
                                <?php
                                foreach ($cate as $k => $m) {
                                    echo "<option value='" . $k . "'>" . $cate[$k] . "</option>";
                                }
                                ?>
                            </select>
                            <span class="help-inline"><?php echo $form->error($model, 'parent'); ?></span>
                        </div>
                    </div>
                    <!--                    <div class="control-group" id="image_cover" style="display:none">
                                            <label class="control-label">Hình Đại Diện</label>
                                            <div class="controls">
                    <?php echo $form->fileField($model, 'cover_image', array('class' => 'id-input-file-1 span5')); ?>
                                                <span class="help-inline" style="float:left;margin-left:390px;"><?php echo $form->error($model, 'cover_image'); ?></span>
                                            </div>
                                        </div>-->
                <?php endif; ?>

                <div class="control-group">
                    <label class="control-label">Tên danh mục sản phẩm</label>
                    <div class="controls">
                        <?php echo $form->textField($model, "name", array('size' => 60, 'maxlength' => 100, 'class' => 'span5', 'placeholder' => 'Tên danh mục sản phẩm')); ?>
                        <span class="help-inline"><?php echo $form->error($model, 'name'); ?></span>
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label">Hiện thị ngoài trang chủ</label>
                    <div class="controls">
                        <select class="span3" name="Category[show_index]" id="show_index">
                            <option value="0">Ẩn</option>
                            <option value="1">Hiển thị</option>                            
                        </select>
                        <span class="help-inline"><?php echo $form->error($model, 'show_index'); ?></span>
                    </div>
                </div>
                <div class="control-group" id="order_index" style="display:none;">
                    <label class="control-label">Thứ tự hiển thị ngoài trang chủ</label>
                    <div class="controls">
                        <?php echo $form->textField($model, "order_index", array('size' => 60, 'maxlength' => 100, 'class' => 'span5', 'placeholder' => 'Thứ tự hiển thị ngoài trang chủ')); ?>
                        <span class="help-inline"><?php echo $form->error($model, 'order_index'); ?></span>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">Hiển thị category này khi click vào menu sản phẩm</label>
                    <div class="controls">
                        <input type="checkbox" name="Category[show_first_product]" style="opacity:1">
                        <span class="help-inline"><?php echo $form->error($model, 'show_first_product'); ?></span>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">Trạng thái</label>
                    <div class="controls">
                        <select class="span3" name="Category[active]">
                            <option value="1">Hiển thị</option>
                            <option value="0">Ẩn</option>
                        </select>
                        <span class="help-inline"><?php echo $form->error($model, 'active'); ?></span>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="form-actions">
                    <button class="btn btn-info" type="submit">
                        <i class="icon-ok bigger-110"></i>
                        Submit
                    </button>
                </div>
            </div>
            <!--PAGE CONTENT ENDS-->
        </div><!--/.span-->
    </div><!--/.row-fluid-->    

</div>
<?php $this->endWidget(); ?>
<script type="text/javascript">
    if(jQuery('#show_index').length){
        jQuery('#show_index').change(function(){
            if(jQuery('#show_index').val() == 1){
                jQuery('#order_index').show();
            }else{
                jQuery('#order_index').hide();
            }
        })
    }
</script>
